<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<CvSearchData>" %>
<%@ Import Namespace="RecruitmentAgency.Models.DataTypes"%>
<%@ Import Namespace="RecruitmentAgency.Models.Utilities.Paging"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Connections - Search CVs
</asp:Content>

<asp:Content ID="MenuLinks" ContentPlaceHolderID="PageMenu" runat="server">
    <div class="centre">
        <% if (ViewData["role"].ToString() == "JobSeeker") { %><div class="subMenuButton" onmouseover="swapBgImage(this)" onclick="javascript:location.href='/Cv/Create'" onmouseout="swapBgImage(this)">Add details</div><% } %>
        <img src="../../Images/RssLogo.png" class="rssLink inline" alt= "Rss logo" onmouseover="swapImage(this)" onmousedown="javascript:location.href='/Cv/CvRssFeed'" onmouseout="swapImage(this)" />
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="viewCvs">
        <% using (Html.BeginForm()) {%>
            <div class="panelTop"></div>
            <div class="panelMiddle padLR20">
                <div class="titleLabel">Search CVs</div>
                Fill one or more fields to search for specific CVs, or leave all fields blank to view all of the CVs.
                <div class="formColumn">                    
                    <div class="formLabel">
                        <label for="PersonName">Job seeker's name:</label>
                    </div>
                    <%= Html.TextBox("PersonName")%>
                    <div class="formLabel">
                        <label for="SkillName">Skill name:</label>
                    </div>
                    <%= Html.DropDownList("SkillName", (SelectList)ViewData["skillNames"], new { @class = "dropDownList" })%>
                    <div class="formLabel">
                        <label for="QualificationType">Qualification type:</label>
                    </div>
                    <%= Html.DropDownList("QualificationType", (SelectList)ViewData["qualificationTypes"], new { @class = "dropDownList" })%>
                    <div class="formLabel">
                        <label for="QualificationSubject">Qualification subject:</label>
                    </div>
                    <%= Html.DropDownList("QualificationSubject", (SelectList)ViewData["qualificationSubjects"], new { @class = "dropDownList" })%>
                </div>
                <div class="formColumn">
                    <div class="formLabel">
                        <label for="MinimumNumberOfGcse">Min. no. of GCSEs:</label>
                    </div>
                    <%= Html.TextBox("MinimumNumberOfGcse")%>
                    <div class="formLabel">
                        <label for="MinimumNumberOfALevel">Min. no. of A-Levels:</label>
                    </div>
                    <%= Html.TextBox("MinimumNumberOfALevel")%>                    
                    <div class="formLabel">
                        <label for="JobSectorPreference">Sector preference:</label>
                    </div>
                    <%= Html.DropDownList("JobSectorPreference", (SelectList)ViewData["sectorPreferences"], new { @class = "dropDownList" })%>
                    <input name="searchPersonButton" class="formButton" id="searchPersonButton" type="submit" value="Search" />
                </div>
            </div>
            <div class="panelBottom"></div>
        <% } %>    
        <div class="panelTop"></div>
        <div class="panelMiddle padLR20">
            <div class="shortTitleLabel">Results</div>
            <div class="floatRight inline marginT5">
                <div class="inline">Number of results in each page: </div>
                <%= Html.DropDownList("PageSize", (SelectList)ViewData["pageSizes"], new { @class = "pageSizeList", onchange = "javascript:location.href='?pageSize=' + this.options[this.selectedIndex].value" })%>
            </div>
            <% foreach (var item in Model.Results) { %>
                <div class="result <%= (ViewData["role"].ToString() == "Admin" && item.NotVerifiedCount > 0 ? "red" : "green") %>" onmouseover="highlightResult(this)" onclick="location.href='/Cv/ViewCv/<%= item.PersonId %>'" onmouseout="normalResult(this)" title="Click to view this CV.">
                    <b><%= Html.Encode(item.FirstName) %> <%= Html.Encode(item.LastName) %></b>
                    <% if (!string.IsNullOrEmpty(item.Town)) { %>
                        from <%= Html.Encode(item.Town) %>
                    <% } %>
                    <% if (item.ContactPreference == "Home phone") { %>
                        (<%= Html.Encode(item.HomePhone) %>)
                    <% } else if (item.ContactPreference == "Mobile phone") { %>
                        (<%= Html.Encode(item.MobilePhone) %>)
                    <% } else if (item.ContactPreference == "Personal e-mail") { %>
                        (<a href="mailto:<%= Html.Encode(item.Email1) %>" title="Click to send an e-mail to <%= Html.Encode(item.FirstName) %> <%= Html.Encode(item.LastName) %>."><%= Html.Encode(item.Email1) %></a>)
                    <% } else if (item.ContactPreference == "Work e-mail") { %>
                        (<a href="mailto:<%= Html.Encode(item.Email2) %>" title="Click to send an e-mail to <%= Html.Encode(item.FirstName) %> <%= Html.Encode(item.LastName) %>."><%= Html.Encode(item.Email2)%></a>)
                    <% } %>
                    <% if (!string.IsNullOrEmpty(item.WebsiteUrl)) { %>
                        <a href="http://www.<%= Html.Encode(item.WebsiteUrl) %>" title="Click to go to <%= Html.Encode(item.FirstName) %> <%= Html.Encode(item.LastName) %>'s website.">www.<%= Html.Encode(item.WebsiteUrl)%></a>
                    <% } %>
                    <% if (!string.IsNullOrEmpty(item.JobSectorPreference)) { %>
                        - <%= Html.Encode(item.JobSectorPreference)%>
                    <% } %>
                    <div class="floatRight">
                        <% if (ViewData["role"].ToString() == "Admin") { %>
                            <% if (item.NotVerifiedCount > 0) { %>
                                <span class="red"><b><%= item.NotVerifiedCount %></b> to be verified &gt;&gt;</span>
                            <% } %>
                            <%= Html.ActionLink("Edit", "Edit", new { id = item.PersonId })%> |
                            <%= Html.ActionLink("Delete", "Delete", new { id = item.PersonId })%>
                        <% } %>
                    </div>
                </div>
            <% } %>
            <% if (Model.Results.Count == 0) { %>
                <div class="floatLeft clear">There are no CVs that match that search selection.</div>
            <% } else { %>
                <div class="floatLeft inline marginT10 clear">Showing <%= Model.PageSize > Model.TotalResultCount ? Model.TotalResultCount : Model.PageSize%> out of <%= Model.TotalResultCount %> results.</div>
                <div class="pager">
                    Page number <%= Model.PageNumber %> out of <%= Math.Ceiling((decimal)Model.TotalResultCount / Model.PageSize) %> <%= Html.Pager(ViewData.Model.PageSize, ViewData.Model.PageNumber, ViewData.Model.TotalResultCount) %>
                </div>
            <% } %>
        </div>        
        <div class="panelBottom"></div>
    </div>
</asp:Content>